<!DOCTYPE html>
<html>

{include file='public/header'}
<style>
    .layui-table-view{
        margin: 0;
    }
</style>
<body>
    <table id="getMessageTemplateList" lay-filter="getMessageTemplateList"></table>
    
    <script type="text/html" id="tbBar">
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete">删除</a>
    </script>
    <script>
        let app_id = GetQueryString('app_id')
        let params = {
            elem: '#getMessageTemplateList'
            , toolbar: '#toolbarDemo'
            , url: '/admin/OpenWeixin/getMessageTemplateList' //数据接口
            , id: 'getMessageTemplateList'
            , page:false
            , where:{app_id}
            , cols: [[ //表头
                { field: 'priTmplId', title: '模版ID'}
                , { field: 'title', title: '模版标题'}
                , { field: 'content', title: '模版内容'}
                , { field: 'type', title: '模版类型', templet: function (d) {
                        return d.type == 2 ? '一次性订阅' : '长期订阅'
                    } 
                }
                , { toolbar: '#tbBar', title: '操作', width:150}
            ]]
        }
        tableList(params)

        layui.use('table', function () {
            var table = layui.table;
            
            table.on('tool(getMessageTemplateList)', function (obj) {
                var event = obj.event;
                if (event === 'delete') {
                    DeleteAjax('/admin/OpenWeixin/deleteMessageTemplate',{ app_id,priTmplId:obj.data.priTmplId },'getMessageTemplateList')
                }
            });
        });
        
        
        
    </script>
</body>

</html>